import { FieldType, SortOrder } from 'choerodon-ui/pro/lib/data-set/enum';
import Record from 'choerodon-ui/pro/lib/data-set/Record';


const treeDataSet = () => ({
  primaryKey: 'id',
  queryUrl: '/_api/tree/table/async',
  submitUrl: '/_api/tree/table/async',
  autoQuery: true,
  parentField: 'parentId',
  idField: 'id',
  expandField: 'expand',
  checkField: 'ischecked',
  fields: [
    { name: 'id', type: FieldType.number },
    { name: 'text', type: FieldType.string, label: '功能名称' },
    { name: 'url', type: FieldType.string, label: '入口页面' },
    { name: 'expand', type: FieldType.boolean, label: '是否展开' },
    { name: 'ischecked', type: FieldType.boolean, label: '是否开启' },
    { name: 'score', type: FieldType.number, order: SortOrder.asc },
    { name: 'parentId', type: FieldType.number, parentField: 'id' },
  ],
  events: {
    indexchange: ({ current }: { current: Record }) => console.log('current user', current),
    submit: ({ data }: { data: Record }) => console.log('submit tree data', data),
  },
});

export default treeDataSet;